package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.pojo.Intervention;
import com.itheima.service.InterventionService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 预约订单处理
 */

@RestController
@RequestMapping("/intervention")
public class InterventionController {
    @Reference
    private InterventionService interventionService;


    //健康建议
    @RequestMapping("/add.do")
    public Result add(@RequestBody Intervention intervention){
        //获取前端传入的数据
        try{
            interventionService.add(intervention);
            return new Result(true,"设置建议成功");
        }catch (Exception e){
            return new Result(false,"设置建议失败");
        }
    }

    //编辑健康建议
    @RequestMapping("/edit")
    public Result edit(@RequestBody Intervention intervention){
        //获取前端传入的数据
        try{
            interventionService.edit(intervention);
            return new Result(true,"更新建议成功");
        }catch (Exception e){
            return new Result(false,"更新建议失败");
        }
    }

    @RequestMapping("/findIntervention.do")
    public Result findIntervention(Integer orderId){
        //获取前端传入的数据
        try{
            Result result = interventionService.findIntervention(orderId);
            return result;
        }catch (Exception e){
            return new Result(false,"设置建议失败");
        }
    }
}
